import service from '@/utils/request';

export const getDockerList = params =>
  service({
    url: '/simulation/res/container/docker/',
    method: 'get',
    params,
  });
// 删除docker
export const delDocker = id =>
  service({
    url: `/simulation/res/container/docker/${id}/`,
    method: 'delete',
  });
// 添加docker
export const addDocker = data =>
  service({
    url: `/simulation/res/container/docker/`,
    method: 'post',
    data,
  });

// 操作docker
export const operationDocker = (id, data) =>
  service({
    url: `/simulation/res/container/docker/${id}/`,
    method: 'post',
    data,
  });
// 编辑docker
export const editorDocker = (id, data) =>
  service({
    url: `/simulation/res/container/docker/${id}/resource/`,
    method: 'put',
    data,
  });
// 容器日志列表  docker
export const getDockerLogs = (id, params) =>
  service({
    url: `simulation/res/container/docker/${id}/log/`,
    method: 'get',
    params,
  });
// 添加网桥  docker
export const addDockerNet = (id, data) =>
  service({
    url: `/simulation/res/container/docker/${id}/network/`,
    method: 'post',
    data,
  });
// 网桥列表  docker
export const getDockerNet = id =>
  service({
    url: `simulation/res/container/docker/${id}/network/`,
    method: 'get',
  });
// 网桥列表  docker
export const editorDockerNet = (id, data) =>
  service({
    url: `/simulation/res/container/docker/${id}/network/`,
    method: 'put',
    data,
  });

export const delDockerNet = (id, data) =>
  service({
    url: `/simulation/res/container/docker/${id}/network/`,
    method: 'delete',
    data,
  });

// 转换docker
export const convertDockerImg = (id, data) =>
  service({
    url: `/simulation/res/container/docker/${id}/convert/`,
    method: 'post',
    data,
  });

// 发送文件
export const sendFileContainer = (id, data) =>
  service({
    url: `/simulation/res/container/docker/${id}/file/`,
    method: 'post',
    data,
  });


/**
 * 容器管理-拓展功能-命令执行
 * @param id
 * @param data
 * @returns {*}
 */
export const commandExecShellApi = (id, data) =>
    service({
        url: `/simulation/res/container/docker/${id}/command/`,
        method: 'post',
        data
    });


/**
 * 命令执行返回结果
 * @param taskID
 * @returns {*}
 */
export const commandExecShellContainerApi = (taskID) =>
    service({
        url: `/simulation/res/container/docker/task/${taskID}/command/`,
        method: 'get'
    });


// 发送文件-最新的
export const sendFileQemuNew = (id, data) =>
    service({
        url: `/simulation/res/container/docker/${id}/file/`,
        method: 'post',
        data,
    });


/**
 * 获取所有一二级节点（通用）
 * @returns {*}
 */
export const getVmNodeAllApi = () =>
    service({
        url: `/simulation/res/computer/tree/`,
        method: 'get'
    });

/**
 * 获取计算节点下虚拟机（树）
 * @returns {*}
 */
export const getVmNodeToVmApi = (id, params) =>
    service({
        url: `/simulation/res/computer/${id}/container/`,
        method: 'get',
        params
    });

/**
 * 查询集群-列表
 * @param id
 * @param params
 * @returns {*}
 */
export const getVMListByClusterApi = (id, params) =>
    service({
        url: `/simulation/res/cluster/${id}/dockerList/`,
        method: 'get',
        params,
    });


/**
 * 查询计算节点-列表
 * @param id
 * @param params
 * @returns {*}
 */
export const getVMListByComputedApi = (id, params) =>
    service({
        url: `/simulation/res/computer/${id}/dockerList/`,
        method: 'get',
        params,
    });

/**
 * 获取容器下概览
 * @param id
 * @returns {*}
 */
export const getVmToOverViewsApi = (id) =>
    service({
        url: `/simulation/res/container/docker/${id}/outline/`,
        method: 'get'
    });


/**
 * 批量操作
 * @param data
 * @returns {*}
 */
export const batchOptionByVmApi = (data) =>
    service({
        url: `/simulation/res/container/docker/batch/`,
        method: 'post',
        data
    });

/**
 * 获取容器下硬件
 * @param id
 * @returns {*}
 */
export const getVmToHardwareApi = (id) =>
    service({
        url: `/simulation/res/container/docker/${id}/hardware/`,
        method: 'get'
    });


/**
 * 编辑容器基本信息（虚拟机名称、硬见基本信息： CPU、内存）
 * @param id
 * @param data
 * @returns {*}
 */
export const editorVmHardWareBaseApi = (id, data) =>
    service({
        url: `/simulation/res/container/docker/${id}/resource/`,
        method: 'put',
        data,
    });


/**
 * 获取树下节点（包含展开懒加载、搜索筛选、滚动加载）
 * @param params
 * @returns {*}
 */
export const getNodeTreeApi = (params) =>
    service({
        url: `/simulation/res/container/docker/tree/`,
        method: 'get',
        params
    });


/**
 * 新增容器
 * @param data
 * @returns {*}
 */
export const addDockerNewApi = data =>
    service({
        url: '/simulation/res/container/docker/',
        method: 'post',
        data,
    });

/**
 * 销毁虚拟机
 * @param id
 * @param data
 * @returns {*}
 */
export const destroyDockerApi = (id, data) =>
    service({
        url: `/simulation/res/container/docker/${id}/destroy/`,
        method: 'post',
        data,
    });

/**
 * 获取容器详情
 * @param id
 * @param params
 * @returns {*}
 */
export const getDockerDetail = (id, params) =>
    service({
        url: `/simulation/res/container/docker/${id}/`,
        method: 'get',
        params,
    });
